package com.zeldu.video.service.impl;

import com.zeldu.common.model.response.CommonCode;
import com.zeldu.video.mapper.VideoMapper;
import com.zeldu.video.pojo.Video;
import com.zeldu.video.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class VideoServiceImpl implements VideoService {

    @Autowired(required = false)
    private VideoMapper videoMapper;


    @Transactional
    @Override
    public List<Video> queryAll() {
        return videoMapper.queryAll();
    }

    @Transactional
    @Override
    public List<Video> queryRecorded(Long course_id, Long id) {
        return videoMapper.queryRecorded(course_id, id);
    }

    @Transactional
    @Override
    public List<Video> queryLive(Long course_id) {
        return videoMapper.queryLive(course_id);
    }

    @Transactional
    @Override
    public int addVideo(Video video) {
        return videoMapper.insert(video);

    }

    @Transactional
    @Override
    public List<Video> queryOnce(Long id) {
        return videoMapper.queryOnce(id);
    }

    @Transactional
    @Override
    public int delVideo(Long id) {
        videoMapper.delVideo(id);
        return 1;
    }

    @Transactional
    @Override
    public List<Video> queryRecordedNew(Long course_id) {
        return videoMapper.queryRecordedNew(course_id);
    }
}
